package com.example.reward.response;

import android.os.Parcel;
import android.os.Parcelable;

import androidx.annotation.NonNull;

// RewardResultDto.java
public class RewardResultDto implements Parcelable {
    private int id;
    private int total;
    private int base;
    private String baseDesc;
    private int extra;
    private String extraDesc;
    private int special;
    private String specialDesc;
    private int totalReward;
    private int currentRank;
    private Integer previousRank;
    private int coreTotal;
    private int generalTotal;
    private boolean previousMetBase;

    private StudentDto studentDto;

    private long timestamp;//  创建时间-时间戳
    // Getters and Setters


    public RewardResultDto(int id, int total, int base, String baseDesc, int extra, String extraDesc, int special, String specialDesc, int totalReward, int currentRank, Integer previousRank, int coreTotal, int generalTotal, boolean previousMetBase, StudentDto studentDto, long timestamp) {
        this.id = id;
        this.total = total;
        this.base = base;
        this.baseDesc = baseDesc;
        this.extra = extra;
        this.extraDesc = extraDesc;
        this.special = special;
        this.specialDesc = specialDesc;
        this.totalReward = totalReward;
        this.currentRank = currentRank;
        this.previousRank = previousRank;
        this.coreTotal = coreTotal;
        this.generalTotal = generalTotal;
        this.previousMetBase = previousMetBase;
        this.studentDto = studentDto;
        this.timestamp = timestamp;
    }

    protected RewardResultDto(Parcel in) {
        id = in.readInt();
        total = in.readInt();
        base = in.readInt();
        baseDesc = in.readString();
        extra = in.readInt();
        extraDesc = in.readString();
        special = in.readInt();
        specialDesc = in.readString();
        totalReward = in.readInt();
        currentRank = in.readInt();
        if (in.readByte() == 0) {
            previousRank = null;
        } else {
            previousRank = in.readInt();
        }
        coreTotal = in.readInt();
        generalTotal = in.readInt();
        previousMetBase = in.readByte() != 0;
        timestamp = in.readLong();

        studentDto = in.readParcelable(StudentDto.class.getClassLoader());
    }

    public static final Creator<RewardResultDto> CREATOR = new Creator<RewardResultDto>() {
        @Override
        public RewardResultDto createFromParcel(Parcel in) {
            return new RewardResultDto(in);
        }

        @Override
        public RewardResultDto[] newArray(int size) {
            return new RewardResultDto[size];
        }
    };

    @Override
    public String toString() {
        return "RewardResultDto{" +
                "id=" + id +
                ", total=" + total +
                ", base=" + base +
                ", baseDesc='" + baseDesc + '\'' +
                ", extra=" + extra +
                ", extraDesc='" + extraDesc + '\'' +
                ", special=" + special +
                ", specialDesc='" + specialDesc + '\'' +
                ", totalReward=" + totalReward +
                ", currentRank=" + currentRank +
                ", previousRank=" + previousRank +
                ", coreTotal=" + coreTotal +
                ", generalTotal=" + generalTotal +
                ", previousMetBase=" + previousMetBase +
                ", studentDto=" + studentDto +
                ", timestamp=" + timestamp +
                '}';
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public int getBase() {
        return base;
    }

    public void setBase(int base) {
        this.base = base;
    }

    public String getBaseDesc() {
        return baseDesc;
    }

    public void setBaseDesc(String baseDesc) {
        this.baseDesc = baseDesc;
    }

    public int getExtra() {
        return extra;
    }

    public void setExtra(int extra) {
        this.extra = extra;
    }

    public String getExtraDesc() {
        return extraDesc;
    }

    public void setExtraDesc(String extraDesc) {
        this.extraDesc = extraDesc;
    }

    public int getSpecial() {
        return special;
    }

    public void setSpecial(int special) {
        this.special = special;
    }

    public String getSpecialDesc() {
        return specialDesc;
    }

    public void setSpecialDesc(String specialDesc) {
        this.specialDesc = specialDesc;
    }

    public int getTotalReward() {
        return totalReward;
    }

    public void setTotalReward(int totalReward) {
        this.totalReward = totalReward;
    }

    public int getCurrentRank() {
        return currentRank;
    }

    public void setCurrentRank(int currentRank) {
        this.currentRank = currentRank;
    }

    public Integer getPreviousRank() {
        return previousRank;
    }

    public void setPreviousRank(Integer previousRank) {
        this.previousRank = previousRank;
    }

    public int getCoreTotal() {
        return coreTotal;
    }

    public void setCoreTotal(int coreTotal) {
        this.coreTotal = coreTotal;
    }

    public int getGeneralTotal() {
        return generalTotal;
    }

    public void setGeneralTotal(int generalTotal) {
        this.generalTotal = generalTotal;
    }

    public boolean isPreviousMetBase() {
        return previousMetBase;
    }

    public void setPreviousMetBase(boolean previousMetBase) {
        this.previousMetBase = previousMetBase;
    }

    public StudentDto getStudentDto() {
        return studentDto;
    }

    public void setStudentDto(StudentDto studentDto) {
        this.studentDto = studentDto;
    }

    public long getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(long timestamp) {
        this.timestamp = timestamp;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        dest.writeInt(id);
        dest.writeInt(total);
        dest.writeInt(base);
        dest.writeString(baseDesc);
        dest.writeInt(extra);
        dest.writeString(extraDesc);
        dest.writeInt(special);
        dest.writeString(specialDesc);
        dest.writeInt(totalReward);
        dest.writeInt(currentRank);
        if (previousRank == null) {
            dest.writeByte((byte) 0);
        } else {
            dest.writeByte((byte) 1);
            dest.writeInt(previousRank);
        }
        dest.writeInt(coreTotal);
        dest.writeInt(generalTotal);
        dest.writeByte((byte) (previousMetBase ? 1 : 0));
        dest.writeLong(timestamp);

        dest.writeParcelable(studentDto, flags);
    }
}